package com.china08.yxyapi.api.manage.sch.platform.website.template;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;

@CrossOrigin
@RestController
public class SwsThemeListController extends YxyApiBaseController {

    @RequestMapping(value = "/api_yw/manage/sch/platform/website/template/theme/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object precess(HttpServletRequest request, HttpServletResponse response, @RequestBody(required = false) ReqModel reqModel) {

        long l1 = System.currentTimeMillis();
        List<Map<String, Object>> themeList = new ArrayList<Map<String, Object>>();

        // 模版id
        String templId = reqModel.templId;
        Assert.isTrue(StringUtils.isNotBlank(templId), "模版id为空");

        //
        if (templId.equals("templ001")) {

            Map<String, Object> m1 = new HashMap<String, Object>();
            m1.put("themeId", "theme001");
            m1.put("themeName", "轻描淡写");
            m1.put("themeDefault", true);
            m1.put("themeImg", "/static/img/website/theme/theme001-icon-1.png");
            m1.put("themeIfImg", "/static/img/website/theme/theme001-iframe-1.jpg");

            Map<String, Object> m2 = new HashMap<String, Object>();
            m2.put("themeId", "theme002");
            m2.put("themeName", "花瓣飘飘");
            m2.put("themeDefault", false);
            m2.put("themeImg", "/static/img/website/theme/theme001-icon-2.png");
            m2.put("themeIfImg", "/static/img/website/theme/theme001-iframe-2.jpg");

            Map<String, Object> m3 = new HashMap<String, Object>();
            m3.put("themeId", "theme003");
            m3.put("themeName", "放飞梦想");
            m3.put("themeDefault", false);
            m3.put("themeImg", "/static/img/website/theme/theme001-icon-3.png");
            m3.put("themeIfImg", "/static/img/website/theme/theme001-iframe-3.jpg");

            themeList.add(m1);
            themeList.add(m2);
            themeList.add(m3);
        }

        //
        else if (templId.equals("templ002")) {

            Map<String, Object> m1 = new HashMap<String, Object>();
            m1.put("themeId", "theme001");
            m1.put("themeName", "轻描淡写");
            m1.put("themeDefault", true);
            m1.put("themeImg", "/static/img/website/theme/theme002-icon-1.png");
            m1.put("themeIfImg", "/static/img/website/theme/theme002-iframe-1.jpg");

            Map<String, Object> m2 = new HashMap<String, Object>();
            m2.put("themeId", "theme002");
            m2.put("themeName", "中规中矩");
            m2.put("themeDefault", false);
            m2.put("themeImg", "/static/img/website/theme/theme002-icon-2.png");
            m2.put("themeIfImg", "/static/img/website/theme/theme002-iframe-2.jpg");

            Map<String, Object> m3 = new HashMap<String, Object>();
            m3.put("themeId", "theme003");
            m3.put("themeName", "方方正正");
            m3.put("themeDefault", false);
            m3.put("themeImg", "/static/img/website/theme/theme002-icon-3.png");
            m3.put("themeIfImg", "/static/img/website/theme/theme002-iframe-3.jpg");

            Map<String, Object> m4 = new HashMap<String, Object>();
            m4.put("themeId", "theme004");
            m4.put("themeName", "圈圈点点");
            m4.put("themeDefault", false);
            m4.put("themeImg", "/static/img/website/theme/theme002-icon-4.png");
            m4.put("themeIfImg", "/static/img/website/theme/theme002-iframe-4.jpg");

            Map<String, Object> m5 = new HashMap<String, Object>();
            m5.put("themeId", "theme005");
            m5.put("themeName", "校园点滴");
            m5.put("themeDefault", false);
            m5.put("themeImg", "/static/img/website/theme/theme002-icon-5.png");
            m5.put("themeIfImg", "/static/img/website/theme/theme002-iframe-5.jpg");

            themeList.add(m1);
            themeList.add(m2);
            themeList.add(m3);
            themeList.add(m4);
            themeList.add(m5);
        } //
        else if (templId.equals("templ101")) {
            Map<String, Object> m1 = new HashMap<String, Object>();
            m1.put("themeId", "theme001");
            m1.put("themeName", "天天向上");
            m1.put("themeDefault", true);
            m1.put("themeImg", "/static/img/website/theme/theme101-icon-1.png");
            m1.put("themeIfImg", "/static/img/website/theme/theme101-iframe-1.jpg");

            Map<String, Object> m2 = new HashMap<String, Object>();
            m2.put("themeId", "theme002");
            m2.put("themeName", "快乐学习");
            m2.put("themeDefault", false);
            m2.put("themeImg", "/static/img/website/theme/theme101-icon-2.png");
            m2.put("themeIfImg", "/static/img/website/theme/theme101-iframe-2.jpg");

            Map<String, Object> m3 = new HashMap<String, Object>();
            m3.put("themeId", "theme003");
            m3.put("themeName", "彩色童年");
            m3.put("themeDefault", false);
            m3.put("themeImg", "/static/img/website/theme/theme101-icon-3.png");
            m3.put("themeIfImg", "/static/img/website/theme/theme101-iframe-3.jpg");

            themeList.add(m1);
            themeList.add(m2);
            themeList.add(m3);
        }
        //
        else if (templId.equals("templ003")) {
            Map<String, Object> m1 = new HashMap<String, Object>();
            m1.put("themeId", "theme001");
            m1.put("themeName", "传统经典");
            m1.put("themeDefault", true);
            m1.put("themeImg", "/static/img/website/theme/theme003-icon-1.png");
            m1.put("themeIfImg", "/static/img/website/theme/theme003-iframe-1.jpg");
            themeList.add(m1);
        }
        RespModel resModel = new RespModel();
        resModel.themeList = themeList;
        System.out.println("获取主题用时：" + (System.currentTimeMillis() - l1));
        return resModel;
    }

    protected static class ReqModel extends YxyApiReqModel {
        public String templId;
    }

    protected class RespModel extends YxyApiRespModel {
        public List<Map<String, Object>> themeList;
    }
}
